<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 3 | Dashboard</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Theme style -->
    <link rel="stylesheet" href="./adminlte/dist/css/adminlte.min.css">
    <style type="text/css">
        html,body {
            height: 100%;
        }
        .login_box {
            border: 1px solid #409EFF;
            border-radius: 13px;
            min-height: 300px;
            margin-top: 90px;
            padding: 30px;
        }
        button {
            margin-top: 32px;
        }
    </style>
</head>
<body>
<div class="wrapper" id="app" v-cloak>
    <div class="container">
        <div class="row">
            <div class="col-lg-4 offset-lg-4">
                <div class="login_box">
                    <div class="form-group">
                        <label>用户名</label>
                        <input v-model="username" type="text" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input v-model="password" type="password" class="form-control">
                    </div>
                    <button @click="login" class="btn btn-success btn-block">登陆</button>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- ./wrapper -->
<!-- 新加js -->
<script src="./dece/js/vue.js"></script>
<script src="./dece/js/axios.min.js"></script>
<script src="./dece/js/app.js"></script>
<script src="./dece/js/vue_component.js"></script>
<script type="text/javascript">
        new Vue({
            el: "#app",
            data: {
                api_host: de.api_host,
                username: '',
                password: '',
            },
            created: function (){
            },
            mounted: function (){
            },
            methods: {
                // 登陆
                login: function (){
                    var the = this;
                    axios.post(de.login, {username:this.username, password:this.password}).then(function (data){
                        var dd = data.data;
                        // console.log(dd);
                        if (dd.code == 200) {
                            // 本地存储token
                            window.localStorage.setItem('login', dd.token);
                            // url重载
                            de.created();
                            // 跳转首页
                            de.href("./index/index.html");
                        } else {
                            alert(dd.info);
                        }
                    }).catch(function(error){
                        console.log(error);
                    });
                },
                
            },
        });
</script>
</body>
</html>
